<template>
	<!-- <web-view src="https://hlxmap.etransferca.info/#/map" @message="onMessage"></web-view> -->


	<!-- 	<view class="content">
		<button @click="nav('/pages/list/list')">列表</button>
		<button @click="nav('/pages/announcement/announcement')">公告</button>
		<button @click="nav('/pages/service/service')">党政服务</button>https://hlxmap.xiangle6.cn
		<button @click="nav('/pages/my/my')">我的</button> http://192.168.0.104:8080/  https://hlxmap.xiangle6.cn/map
	</view> -->
	<view class="">
		<web-view @loaded="loaded" src="https://hlxmap.xiangle6.cn/map" @message="onMessage"></web-view>
		<Loading ref="loading" />
	</view>

</template>

<script>
	import Loading from '@/components/loding.vue'
	export default {
		data() {
			return {
				url: ''
			}
		},
		components: {
			Loading
		},
		async onLoad() {
			// this.$request('/api/type/share_title', {}, 'get').then(res => {})
			// await getApp().login()
			this.$refs.loading.init()
			this.$refs.loading.progress = 100
			// return
			// if (uni.getStorageSync('userId') && uni.getStorageSync('token')) {
			// 	this.url = `http://192.168.0.104:8080/map?id=` + uni.getStorageSync('userId')
			// 	const socket = uni.connectSocket({
			// 		url: `wss://hlx.xiangle6.cn/imserver/${uni.getStorageSync('userId')}/wxmini`,
			// 		success(res) {
			// 			console.log('cehngg ',res)
			// 			setTimeout(() => {
			// 				uni.sendSocketMessage({
			// 					data:111
			// 				});
			// 			},1000)
			// 			// setInterval(() => {
			// 			// 		uni.sendSocketMessage({
			// 			// 			data: '111'
			// 			// 		});
			// 			// 	},30000)
			// 		}
			// 	})
				
			// 	return
			// }
			// wx.login({
			// 	success: async (e) => {
			// 		const res = await this.$request(
			// 			`/api/login?code=${e.code}&appids=wxce9af358240d359c&secret=7bb54ee600e9261fabfb02a2a8d46d0e`, {
			// 				code: e.code,
			// 				appids: 'wxce9af358240d359c',
			// 				secret: '7bb54ee600e9261fabfb02a2a8d46d0e'
			// 			})
			// 		uni.setStorageSync('token', res.data.token)
			// 		const res2 = await this.$request('/api/userInfo', {}, 'get')
			// 		uni.setStorageSync('userinfo', res2.data.data)
			// 		// this.globalData.token = 
			// 		this.url = `http://192.168.0.103:8080/map?id=` + res2.data.data.id
			// 		uni.setStorageSync('userId', res2.data.data.id)
			// 		const socket = uni.connectSocket({
			// 			url: `wss://hlx.xiangle6.cn/imserver/${res2.data.data.id}/wxmini`
			// 		})
			// 		uni.onSocketMessage(function(res) {
			// 			console.log('收到服务器内容：' + res.data);
			// 		});
			// 	}
			// })
			// const res = await request(
			// 	`/api/login?code=${e.code}&appids=wxce9af358240d359c&secret=7bb54ee600e9261fabfb02a2a8d46d0e`, {
			// 		code: e.code,
			// 		appids: 'wxce9af358240d359c',
			// 		secret: '7bb54ee600e9261fabfb02a2a8d46d0e'
			// 	})
		},
		onShareAppMessage() {
			const promise = new Promise(resolve => {
				this.$request('/api/type/share_title', {}, 'get').then(res => {
					const obj = res.data.data.find(item => item.dictLabel == 'index_share_title')
					console.log(obj)
					resolve({
						title: JSON.parse(obj?.dictValue || '[]')[Math.floor(Math.random() * JSON
							.parse(obj?.dictValue || '[]').length)] || '黄龙溪'
					})
				})
			})
			return {
				title: '自定义转发标题',
				path: '/pages/index/index',
				promise
			}
		},
		onShareTimeline() {
			return {
				title: '黄龙溪概况',
				path: '/pages/index/index',
			}
		},
		methods: {
			loaded() {
				setTimeout(() => {
					this.$refs.loading.destoryed()
				}, 500)
			},
			nav(url) {
				uni.navigateTo({
					url: url
				})
			},
			onMessage(e) {
				uni.getLocation({
					success(res) {
						console.log()
					}
				})
			}

		}
	}
</script>

<style>
</style>